package com.thread.core;

import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程模型
 * @author asd
 *
 */
public class ThreadService {
	private ThreadPoolExecutor threadPool= null;
	
	
	public void start(){
		threadPool = new ThreadPoolExecutor(20,1000,200L,TimeUnit.SECONDS,new LinkedTransferQueue<Runnable>(),new ThreadFactory()
		{
			public Thread newThread(Runnable r)
			{
				return new Thread(r,this.getClass().getName());
			}
		});
		
		threadPool.allowCoreThreadTimeOut(true);
	}

	public ThreadPoolExecutor getThreadPool() {
		return threadPool;
	}

	public void setThreadPool(ThreadPoolExecutor threadPool) {
		this.threadPool = threadPool;
	}
	
}
